package com.caoyuqi.picture.service;

import com.caoyuqi.picture.mapper.LoginMapper;
import com.caoyuqi.picture.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class LoginService {
    @Autowired
    LoginMapper loginMapper;
    public boolean LoginSuccess(String username,String pwd)
    {
        User user = loginMapper.queryLogin(username,pwd);
        return user!=null;
    }
    public boolean isAdmin(User user) {
        User admin = loginMapper.isAdmin(user.getUsername(), user.getPwd(), user.getAdmin());
        if (admin.getAdmin().equals("true")) {
            return true;
        } else {
            return false;
        }
    }
    public ArrayList<User> QueryAll()
    {
        ArrayList<User> users = loginMapper.queryAll();
        return users;
    }
}
